<template>
	<view class="content">
		<view v-if="content">
			<view class="news-title">{{title}}</view>
			<img :src="cover.url" class="fm-img"/>
			<u-parse :content="content"></u-parse>
		</view>
		<mescroll-empty v-else></mescroll-empty>
	</view>
</template>

<script>
	import MescrollEmpty from '@/uni_modules/mescroll-uni/components/mescroll-empty/mescroll-empty.vue';
	export default {
		components: {
			MescrollEmpty
		},
		data() {
			return {
				title: "",
				content: ""
			}
		},
		onLoad(options) {
			options.id && this.getDetails(options.id);
		},
		methods: {
			async getDetails(id) {
				let res = await uniCloud.callFunction({
					name: 'newsDetails',
					data: {
						id: id
					}
				});
				console.log(res);
				const data = res.result.data;
				if (data.length) {
					this.title = data[0].title;
					this.content = data[0].content;
					this.cover = data[0].cover;
				}
			}
		}
	}
</script>

<style lang="scss" scope>
.content {
  padding: 30rpx;
  color: $u-content-color;
  font-size: 32rpx;
  line-height: 1.8;

  .news-title {
    font-size: 48rpx;
    margin-bottom: 30rpx;
    text-align: center; /* 标题居中 */
  }

  img.fm-img {
    max-width: 100%;
    height: 200px;
    margin-bottom: 20px;
  }

  p {
    color: $u-tips-color;
    margin-bottom: 10px;
    text-indent: 2em; /* 首行缩进两个字符 */
  }
}
	
	
</style>